﻿using GrapeCity.Forguncy.CellTypes;
using GrapeCity.Forguncy.Commands;
using GrapeCity.Forguncy.Plugin;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace Vant
{
    internal class SRDisplayNameAttribute : DisplayNameAttribute
    {
        public SRDisplayNameAttribute(string name)
            : base(ResourceHelper.GetString(name))
        {
        }
    }
    internal class SRFormulaPropertyAttribute : FormulaPropertyAttribute
    {
        public SRFormulaPropertyAttribute()
        {
        }
        public override string ContextVariables
        {
            get => ResourceHelper.GetString(base.ContextVariables);
            set => base.ContextVariables = value;
        }
    }
    internal class SRDescriptionAttribute : DescriptionAttribute
    {
        public SRDescriptionAttribute(string name)
            : base(ResourceHelper.GetString(name))
        {
        }
    }

    internal class SRCategoryAttribute : CategoryAttribute
    {
        public SRCategoryAttribute(string category)
            : base(ResourceHelper.GetString(category))
        {
        }
    }
    internal class SRItemDisplayNameAttribute : ItemDisplayNameAttribute
    {
        public SRItemDisplayNameAttribute(string name)
            : base(ResourceHelper.GetString(name))
        {
        }
    }
    
    internal class SRCustomCommandObjectAttribute : CustomCommandObjectAttribute
    {
        public override string InitParamValues
        {
            get => ResourceHelper.GetString(base.InitParamValues);
            set => base.InitParamValues = value;
        }
    }
    internal class SRBindingDataSourcePropertyAttribute : BindingDataSourcePropertyAttribute
    {
        public override string Columns
        {
            get => ResourceHelper.GetString(base.Columns);
            set => base.Columns = value;
        }
        public override string ColumnsDescription
        {
            get => ResourceHelper.GetString(base.ColumnsDescription);
            set => base.ColumnsDescription = value;
        }
    }
    internal class SRTreePropertyAttribute : TreePropertyAttribute
    {
        public override string DefaultNodeName
        {
            get => ResourceHelper.GetString(base.DefaultNodeName);
            set => base.DefaultNodeName = value;
        }
    }
    internal class SRComboPropertyAttribute : ComboPropertyAttribute
    {
        public override string DisplayList
        {
            get => ResourceHelper.GetString(base.DisplayList);
            set => base.DisplayList = value;
        }
        public override string ValueList
        {
            get => ResourceHelper.GetString(base.ValueList);
            set => base.ValueList = value;
        }
    }
    internal class SRRadioGroupPropertyAttribute : RadioGroupPropertyAttribute
    {
        public override string DisplayList
        {
            get => ResourceHelper.GetString(base.DisplayList);
            set => base.DisplayList = value;
        }
        public override string ValueList
        {
            get => ResourceHelper.GetString(base.ValueList);
            set => base.ValueList = value;
        }
    }
    internal class SRCategoryHeaderAttribute : CategoryHeaderAttribute
    {
        public SRCategoryHeaderAttribute(string name)
            : base(ResourceHelper.GetString(name))
        {
        }
    }
    internal class SRIntPropertyAttribute : IntPropertyAttribute
    {
        public override string Watermark
        {
            get => ResourceHelper.GetString(base.Watermark);
            set => base.Watermark = value;
        }
    }
    internal class SRDoublePropertyAttribute : DoublePropertyAttribute
    {
        public override string Watermark
        {
            get => ResourceHelper.GetString(base.Watermark);
            set => base.Watermark = value;
        }
    }

    internal class SRObjectListProperty : ObjectListPropertyAttribute
    {
        public override string DefaultName 
        {
            get => ResourceHelper.GetString(base.DefaultName);
            set => base.DefaultName = value;
        }
    }

    static class ResourceHelper
    {
        public static string GetString(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return name;
            }
            var srStr = Properties.Resources.ResourceManager.GetString(name);
            if (srStr == null)
            {
                return name;
            }
            return srStr;
        }
    }
    internal class IconPropertyAttribute : ImageValuePropertyAttribute
    {
        public IconPropertyAttribute()
        {
            this.SupportUseCellColor = false;
            this.DefaultActiveTabIndex = 1;
            this.DefaultIconColor = "#c0c4cc";
        }
    }
}
